package com.cennavi.buss.service;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.cennavi.minemap.bean.MessageBean;

public abstract class AbstractService {
    
    Logger logger = LoggerFactory.getLogger(AbstractService.class);
    
    public MessageBean createMsgBean(String errmsg) {
        MessageBean messageBean = new MessageBean();
        messageBean.setErrcode(-998);
        messageBean.setErrmsg(errmsg);
        return messageBean;
    }

    public MessageBean createMsgBean() {
        InetAddress address = null;
        try {
            address = InetAddress.getLocalHost();
        } catch (UnknownHostException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        MessageBean messageBean = new MessageBean();
        messageBean.setErrcode(-998);
        logger.error("连接" + address.getHostAddress() + "服务超时或者无法访问。");
        messageBean.setErrmsg("服务超时或者无法访问。");
        return messageBean;
    }
}
